/*
 * HubEntry.java
 *
 * Created on 12 November 2006, 01:09
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package libjdc.hublist;

/**
 *
 * @author root
 */
public class HubEntry implements Comparable{
    
    private String name;
    private String address;
    private String description;
    private int users;
    private String country;
    private String shared;
    private String status;
    private String min_share;
    private String min_slots;
    private String max_hubs;
    private String max_users;
    private String reliability;
    private String rating;
    private String port;
    
    /** Creates a new instance of HubEntry */
    public HubEntry(
            String name,
            String address,
            String description,
            int users,
            String country,
            String shared,
            String status,
            String min_share,
            String min_slots,
            String max_hubs,
            String max_users,
            String reliability,
            String rating,
            String port
            ) {
        this.setName(name);
        this.setAddress(address);
        this.setDescription(description);
        this.users = users;
        this.setCountry(country);
        this.setShared(shared);
        this.setStatus(status);
        this.setMin_share(min_share);
        this.setMin_slots(min_slots);
        this.setMax_hubs(max_hubs);
        this.setMax_users(max_users);
        this.setReliability(reliability);
        this.setRating(rating);
        this.setPort(port);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getShared() {
        return shared;
    }

    public void setShared(String shared) {
        this.shared = shared;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMin_share() {
        return min_share;
    }

    public void setMin_share(String min_share) {
        this.min_share = min_share;
    }

    public String getMin_slots() {
        return min_slots;
    }

    public void setMin_slots(String min_slots) {
        this.min_slots = min_slots;
    }

    public String getMax_hubs() {
        return max_hubs;
    }

    public void setMax_hubs(String max_hubs) {
        this.max_hubs = max_hubs;
    }

    public String getMax_users() {
        return max_users;
    }

    public void setMax_users(String max_users) {
        this.max_users = max_users;
    }

    public String getReliability() {
        return reliability;
    }

    public void setReliability(String reliability) {
        this.reliability = reliability;
    }

    public String getRating() {
        return rating;
    }

    public void setRating(String rating) {
        this.rating = rating;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }
    
    private boolean hasPort411(String address){
        int idx = address.indexOf(":")+1;
        return address.substring(idx).equals("411");
    }
    
    private String removePort(String address){
        return (hasPort411(address))? address.substring(0,address.indexOf(":")) : address;
    }

    public int compareTo(Object o) {
        
        return removePort(this.getAddress()).compareTo( removePort((( HubEntry) o).getAddress()) );
    }

    public int getUsers() {
        return users;
    }

    public void setUsers(int users) {
        this.users = users;
    }
    
}
